package gui;

import javax.swing.*;
import java.awt.Component;
import javax.swing.table.TableCellRenderer;

/**
 * A class to implement Combo boxes in a JTable in AddHouseholdGui.java
 * @author Sarah Wegner
 */
public class AddComboBoxRenderer extends JComboBox implements TableCellRenderer {
    public AddComboBoxRenderer(String[] items) {
        super(items);
    }//AddComboBoxRenderer

    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {

        if (isSelected) {
            setForeground(table.getSelectionForeground());
            super.setBackground(table.getSelectionBackground());
        }//if
        else {
            setForeground(table.getForeground());
            setBackground(table.getBackground());
        }//else

        // Select the current value
        setSelectedItem(value);
        return this;
    }//getTableCellRendererComponent

}//AddComboBoxRenderer